<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Instruction Output (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Instruction Output (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Instruction Output (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Assembler-Format.html" rel="up" title="Assembler Format">
<link href="Dispatch-Tables.html" rel="next" title="Dispatch Tables">
<link href="Macros-for-Initialization.html" rel="prev" title="Macros for Initialization">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>


</head>

<body lang="en">
<div class="subsection-level-extent" id="Instruction-Output">
<div class="nav-panel">
<p>
Next: <a href="Dispatch-Tables.html" accesskey="n" rel="next">Output of Dispatch Tables</a>, Previous: <a href="Macros-for-Initialization.html" accesskey="p" rel="prev">Macros Controlling Initialization Routines</a>, Up: <a href="Assembler-Format.html" accesskey="u" rel="up">Defining the Output Assembler Language</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="Output-of-Assembler-Instructions"><span>18.20.7 Output of Assembler Instructions<a class="copiable-link" href="#Output-of-Assembler-Instructions"> &para;</a></span></h4>

<p>This describes assembler instruction output.
</p>
<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-REGISTER_005fNAMES"><span class="category-def">Macro: </span><span><strong class="def-name">REGISTER_NAMES</strong><a class="copiable-link" href="#index-REGISTER_005fNAMES"> &para;</a></span></dt>
<dd><p>A C initializer containing the assembler&rsquo;s names for the machine
registers, each one as a C string constant.  This is what translates
register numbers in the compiler into assembler language.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-ADDITIONAL_005fREGISTER_005fNAMES"><span class="category-def">Macro: </span><span><strong class="def-name">ADDITIONAL_REGISTER_NAMES</strong><a class="copiable-link" href="#index-ADDITIONAL_005fREGISTER_005fNAMES"> &para;</a></span></dt>
<dd><p>If defined, a C initializer for an array of structures containing a name
and a register number.  This macro defines additional names for hard
registers, thus allowing the <code class="code">asm</code> option in declarations to refer
to registers using alternate names.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-OVERLAPPING_005fREGISTER_005fNAMES"><span class="category-def">Macro: </span><span><strong class="def-name">OVERLAPPING_REGISTER_NAMES</strong><a class="copiable-link" href="#index-OVERLAPPING_005fREGISTER_005fNAMES"> &para;</a></span></dt>
<dd><p>If defined, a C initializer for an array of structures containing a
name, a register number and a count of the number of consecutive
machine registers the name overlaps.  This macro defines additional
names for hard registers, thus allowing the <code class="code">asm</code> option in
declarations to refer to registers using alternate names.  Unlike
<code class="code">ADDITIONAL_REGISTER_NAMES</code>, this macro should be used when the
register name implies multiple underlying registers.
</p>
<p>This macro should be used when it is important that a clobber in an
<code class="code">asm</code> statement clobbers all the underlying values implied by the
register name.  For example, on ARM, clobbering the double-precision
VFP register &ldquo;d0&rdquo; implies clobbering both single-precision registers
&ldquo;s0&rdquo; and &ldquo;s1&rdquo;.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-ASM_005fOUTPUT_005fOPCODE"><span class="category-def">Macro: </span><span><strong class="def-name">ASM_OUTPUT_OPCODE</strong> <var class="def-var-arguments">(<var class="var">stream</var>, <var class="var">ptr</var>)</var><a class="copiable-link" href="#index-ASM_005fOUTPUT_005fOPCODE"> &para;</a></span></dt>
<dd><p>Define this macro if you are using an unusual assembler that
requires different names for the machine instructions.
</p>
<p>The definition is a C statement or statements which output an
assembler instruction opcode to the stdio stream <var class="var">stream</var>.  The
macro-operand <var class="var">ptr</var> is a variable of type <code class="code">char *</code> which
points to the opcode name in its &ldquo;internal&rdquo; form&mdash;the form that is
written in the machine description.  The definition should output the
opcode name to <var class="var">stream</var>, performing any translation you desire, and
increment the variable <var class="var">ptr</var> to point at the end of the opcode
so that it will not be output twice.
</p>
<p>In fact, your macro definition may process less than the entire opcode
name, or more than the opcode name; but if you want to process text
that includes &lsquo;<samp class="samp">%</samp>&rsquo;-sequences to substitute operands, you must take
care of the substitution yourself.  Just be sure to increment
<var class="var">ptr</var> over whatever text should not be output normally.
</p>
<a class="index-entry-id" id="index-recog_005fdata_002eoperand"></a>
<p>If you need to look at the operand values, they can be found as the
elements of <code class="code">recog_data.operand</code>.
</p>
<p>If the macro definition does nothing, the instruction is output
in the usual way.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-FINAL_005fPRESCAN_005fINSN"><span class="category-def">Macro: </span><span><strong class="def-name">FINAL_PRESCAN_INSN</strong> <var class="def-var-arguments">(<var class="var">insn</var>, <var class="var">opvec</var>, <var class="var">noperands</var>)</var><a class="copiable-link" href="#index-FINAL_005fPRESCAN_005fINSN"> &para;</a></span></dt>
<dd><p>If defined, a C statement to be executed just prior to the output of
assembler code for <var class="var">insn</var>, to modify the extracted operands so
they will be output differently.
</p>
<p>Here the argument <var class="var">opvec</var> is the vector containing the operands
extracted from <var class="var">insn</var>, and <var class="var">noperands</var> is the number of
elements of the vector which contain meaningful data for this insn.
The contents of this vector are what will be used to convert the insn
template into assembler code, so you can change the assembler output
by changing the contents of the vector.
</p>
<p>This macro is useful when various assembler syntaxes share a single
file of instruction patterns; by defining this macro differently, you
can cause a large class of instructions to be output differently (such
as with rearranged operands).  Naturally, variations in assembler
syntax affecting individual insn patterns ought to be handled by
writing conditional output routines in those patterns.
</p>
<p>If this macro is not defined, it is equivalent to a null statement.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-TARGET_005fASM_005fFINAL_005fPOSTSCAN_005fINSN"><span class="category-def">Target Hook: </span><span><code class="def-type">void</code> <strong class="def-name">TARGET_ASM_FINAL_POSTSCAN_INSN</strong> <code class="def-code-arguments">(FILE *<var class="var">file</var>, rtx_insn *<var class="var">insn</var>, rtx *<var class="var">opvec</var>, int <var class="var">noperands</var>)</code><a class="copiable-link" href="#index-TARGET_005fASM_005fFINAL_005fPOSTSCAN_005fINSN"> &para;</a></span></dt>
<dd><p>If defined, this target hook is a function which is executed just after the
output of assembler code for <var class="var">insn</var>, to change the mode of the assembler
if necessary.
</p>
<p>Here the argument <var class="var">opvec</var> is the vector containing the operands
extracted from <var class="var">insn</var>, and <var class="var">noperands</var> is the number of
elements of the vector which contain meaningful data for this insn.
The contents of this vector are what was used to convert the insn
template into assembler code, so you can change the assembler mode
by checking the contents of the vector.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-PRINT_005fOPERAND"><span class="category-def">Macro: </span><span><strong class="def-name">PRINT_OPERAND</strong> <var class="def-var-arguments">(<var class="var">stream</var>, <var class="var">x</var>, <var class="var">code</var>)</var><a class="copiable-link" href="#index-PRINT_005fOPERAND"> &para;</a></span></dt>
<dd><p>A C compound statement to output to stdio stream <var class="var">stream</var> the
assembler syntax for an instruction operand <var class="var">x</var>.  <var class="var">x</var> is an
RTL expression.
</p>
<p><var class="var">code</var> is a value that can be used to specify one of several ways
of printing the operand.  It is used when identical operands must be
printed differently depending on the context.  <var class="var">code</var> comes from
the &lsquo;<samp class="samp">%</samp>&rsquo; specification that was used to request printing of the
operand.  If the specification was just &lsquo;<samp class="samp">%<var class="var">digit</var></samp>&rsquo; then
<var class="var">code</var> is 0; if the specification was &lsquo;<samp class="samp">%<var class="var">ltr</var>
<var class="var">digit</var></samp>&rsquo; then <var class="var">code</var> is the ASCII code for <var class="var">ltr</var>.
</p>
<a class="index-entry-id" id="index-reg_005fnames-1"></a>
<p>If <var class="var">x</var> is a register, this macro should print the register&rsquo;s name.
The names can be found in an array <code class="code">reg_names</code> whose type is
<code class="code">char *[]</code>.  <code class="code">reg_names</code> is initialized from
<code class="code">REGISTER_NAMES</code>.
</p>
<p>When the machine description has a specification &lsquo;<samp class="samp">%<var class="var">punct</var></samp>&rsquo;
(a &lsquo;<samp class="samp">%</samp>&rsquo; followed by a punctuation character), this macro is called
with a null pointer for <var class="var">x</var> and the punctuation character for
<var class="var">code</var>.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-PRINT_005fOPERAND_005fPUNCT_005fVALID_005fP"><span class="category-def">Macro: </span><span><strong class="def-name">PRINT_OPERAND_PUNCT_VALID_P</strong> <var class="def-var-arguments">(<var class="var">code</var>)</var><a class="copiable-link" href="#index-PRINT_005fOPERAND_005fPUNCT_005fVALID_005fP"> &para;</a></span></dt>
<dd><p>A C expression which evaluates to true if <var class="var">code</var> is a valid
punctuation character for use in the <code class="code">PRINT_OPERAND</code> macro.  If
<code class="code">PRINT_OPERAND_PUNCT_VALID_P</code> is not defined, it means that no
punctuation characters (except for the standard one, &lsquo;<samp class="samp">%</samp>&rsquo;) are used
in this way.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-PRINT_005fOPERAND_005fADDRESS"><span class="category-def">Macro: </span><span><strong class="def-name">PRINT_OPERAND_ADDRESS</strong> <var class="def-var-arguments">(<var class="var">stream</var>, <var class="var">x</var>)</var><a class="copiable-link" href="#index-PRINT_005fOPERAND_005fADDRESS"> &para;</a></span></dt>
<dd><p>A C compound statement to output to stdio stream <var class="var">stream</var> the
assembler syntax for an instruction operand that is a memory reference
whose address is <var class="var">x</var>.  <var class="var">x</var> is an RTL expression.
</p>
<a class="index-entry-id" id="index-TARGET_005fENCODE_005fSECTION_005fINFO-usage"></a>
<p>On some machines, the syntax for a symbolic address depends on the
section that the address refers to.  On these machines, define the hook
<code class="code">TARGET_ENCODE_SECTION_INFO</code> to store the information into the
<code class="code">symbol_ref</code>, and then check for it here.  See <a class="xref" href="Assembler-Format.html">Defining the Output Assembler Language</a>.
</p></dd></dl>

<a class="index-entry-id" id="index-dbr_005fsequence_005flength"></a>
<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-DBR_005fOUTPUT_005fSEQEND"><span class="category-def">Macro: </span><span><strong class="def-name">DBR_OUTPUT_SEQEND</strong> <var class="def-var-arguments">(<var class="var">file</var>)</var><a class="copiable-link" href="#index-DBR_005fOUTPUT_005fSEQEND"> &para;</a></span></dt>
<dd><p>A C statement, to be executed after all slot-filler instructions have
been output.  If necessary, call <code class="code">dbr_sequence_length</code> to
determine the number of slots filled in a sequence (zero if not
currently outputting a sequence), to decide how many no-ops to output,
or whatever.
</p>
<p>Don&rsquo;t define this macro if it has nothing to do, but it is helpful in
reading assembly output if the extent of the delay sequence is made
explicit (e.g. with white space).
</p></dd></dl>

<a class="index-entry-id" id="index-final_005fsequence"></a>
<p>Note that output routines for instructions with delay slots must be
prepared to deal with not being output as part of a sequence
(i.e. when the scheduling pass is not run, or when no slot fillers could be
found.)  The variable <code class="code">final_sequence</code> is null when not
processing a sequence, otherwise it contains the <code class="code">sequence</code> rtx
being output.
</p>
<a class="index-entry-id" id="index-asm_005ffprintf"></a>
<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-REGISTER_005fPREFIX"><span class="category-def">Macro: </span><span><strong class="def-name">REGISTER_PREFIX</strong><a class="copiable-link" href="#index-REGISTER_005fPREFIX"> &para;</a></span></dt>
<dt class="deffnx defmacx-alias-deffnx def-cmd-deffn" id="index-LOCAL_005fLABEL_005fPREFIX"><span class="category-def">Macro: </span><span><strong class="def-name">LOCAL_LABEL_PREFIX</strong><a class="copiable-link" href="#index-LOCAL_005fLABEL_005fPREFIX"> &para;</a></span></dt>
<dt class="deffnx defmacx-alias-deffnx def-cmd-deffn" id="index-USER_005fLABEL_005fPREFIX"><span class="category-def">Macro: </span><span><strong class="def-name">USER_LABEL_PREFIX</strong><a class="copiable-link" href="#index-USER_005fLABEL_005fPREFIX"> &para;</a></span></dt>
<dt class="deffnx defmacx-alias-deffnx def-cmd-deffn" id="index-IMMEDIATE_005fPREFIX"><span class="category-def">Macro: </span><span><strong class="def-name">IMMEDIATE_PREFIX</strong><a class="copiable-link" href="#index-IMMEDIATE_005fPREFIX"> &para;</a></span></dt>
<dd><p>If defined, C string expressions to be used for the &lsquo;<samp class="samp">%R</samp>&rsquo;, &lsquo;<samp class="samp">%L</samp>&rsquo;,
&lsquo;<samp class="samp">%U</samp>&rsquo;, and &lsquo;<samp class="samp">%I</samp>&rsquo; options of <code class="code">asm_fprintf</code> (see
<samp class="file">final.cc</samp>).  These are useful when a single <samp class="file">md</samp> file must
support multiple assembler formats.  In that case, the various <samp class="file">tm.h</samp>
files can define these macros differently.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-ASM_005fFPRINTF_005fEXTENSIONS"><span class="category-def">Macro: </span><span><strong class="def-name">ASM_FPRINTF_EXTENSIONS</strong> <var class="def-var-arguments">(<var class="var">file</var>, <var class="var">argptr</var>, <var class="var">format</var>)</var><a class="copiable-link" href="#index-ASM_005fFPRINTF_005fEXTENSIONS"> &para;</a></span></dt>
<dd><p>If defined this macro should expand to a series of <code class="code">case</code>
statements which will be parsed inside the <code class="code">switch</code> statement of
the <code class="code">asm_fprintf</code> function.  This allows targets to define extra
printf formats which may useful when generating their assembler
statements.  Note that uppercase letters are reserved for future
generic extensions to asm_fprintf, and so are not available to target
specific code.  The output file is given by the parameter <var class="var">file</var>.
The varargs input pointer is <var class="var">argptr</var> and the rest of the format
string, starting the character after the one that is being switched
upon, is pointed to by <var class="var">format</var>.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-ASSEMBLER_005fDIALECT"><span class="category-def">Macro: </span><span><strong class="def-name">ASSEMBLER_DIALECT</strong><a class="copiable-link" href="#index-ASSEMBLER_005fDIALECT"> &para;</a></span></dt>
<dd><p>If your target supports multiple dialects of assembler language (such as
different opcodes), define this macro as a C expression that gives the
numeric index of the assembler language dialect to use, with zero as the
first variant.
</p>
<p>If this macro is defined, you may use constructs of the form
</p><div class="example smallexample">
<pre class="example-preformatted">&lsquo;<samp class="samp">{option0|option1|option2...}</samp>&rsquo;
</pre></div>
<p>in the output templates of patterns (see <a class="pxref" href="Output-Template.html">Output Templates and Operand Substitution</a>) or in the
first argument of <code class="code">asm_fprintf</code>.  This construct outputs
&lsquo;<samp class="samp">option0</samp>&rsquo;, &lsquo;<samp class="samp">option1</samp>&rsquo;, &lsquo;<samp class="samp">option2</samp>&rsquo;, etc., if the value of
<code class="code">ASSEMBLER_DIALECT</code> is zero, one, two, etc.  Any special characters
within these strings retain their usual meaning.  If there are fewer
alternatives within the braces than the value of
<code class="code">ASSEMBLER_DIALECT</code>, the construct outputs nothing. If it&rsquo;s needed
to print curly braces or &lsquo;<samp class="samp">|</samp>&rsquo; character in assembler output directly,
&lsquo;<samp class="samp">%{</samp>&rsquo;, &lsquo;<samp class="samp">%}</samp>&rsquo; and &lsquo;<samp class="samp">%|</samp>&rsquo; can be used.
</p>
<p>If you do not define this macro, the characters &lsquo;<samp class="samp">{</samp>&rsquo;, &lsquo;<samp class="samp">|</samp>&rsquo; and
&lsquo;<samp class="samp">}</samp>&rsquo; do not have any special meaning when used in templates or
operands to <code class="code">asm_fprintf</code>.
</p>
<p>Define the macros <code class="code">REGISTER_PREFIX</code>, <code class="code">LOCAL_LABEL_PREFIX</code>,
<code class="code">USER_LABEL_PREFIX</code> and <code class="code">IMMEDIATE_PREFIX</code> if you can express
the variations in assembler language syntax with that mechanism.  Define
<code class="code">ASSEMBLER_DIALECT</code> and use the &lsquo;<samp class="samp">{option0|option1}</samp>&rsquo; syntax
if the syntax variant are larger and involve such things as different
opcodes or operand order.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-ASM_005fOUTPUT_005fREG_005fPUSH"><span class="category-def">Macro: </span><span><strong class="def-name">ASM_OUTPUT_REG_PUSH</strong> <var class="def-var-arguments">(<var class="var">stream</var>, <var class="var">regno</var>)</var><a class="copiable-link" href="#index-ASM_005fOUTPUT_005fREG_005fPUSH"> &para;</a></span></dt>
<dd><p>A C expression to output to <var class="var">stream</var> some assembler code
which will push hard register number <var class="var">regno</var> onto the stack.
The code need not be optimal, since this macro is used only when
profiling.
</p></dd></dl>

<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-ASM_005fOUTPUT_005fREG_005fPOP"><span class="category-def">Macro: </span><span><strong class="def-name">ASM_OUTPUT_REG_POP</strong> <var class="def-var-arguments">(<var class="var">stream</var>, <var class="var">regno</var>)</var><a class="copiable-link" href="#index-ASM_005fOUTPUT_005fREG_005fPOP"> &para;</a></span></dt>
<dd><p>A C expression to output to <var class="var">stream</var> some assembler code
which will pop hard register number <var class="var">regno</var> off of the stack.
The code need not be optimal, since this macro is used only when
profiling.
</p></dd></dl>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Dispatch-Tables.html">Output of Dispatch Tables</a>, Previous: <a href="Macros-for-Initialization.html">Macros Controlling Initialization Routines</a>, Up: <a href="Assembler-Format.html">Defining the Output Assembler Language</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
